﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Gakita.View
{
    /* This class handles the logic for the particles created by the particlesystem */
    class Particle
    {
        private Vector2 _position;
        private Vector2 _velocity;
        public float _lifeTime;
        private float _originalLifeTime;
        public float _angle;
        private float _angularVelocity;
        public Color _color                     =       Color.Black;

        public Particle(Vector2 aPosition, Vector2 aVelocity, float aLifeTime, float aAngle, float aAngularVelocity)
        {
            _position = aPosition;
            _velocity = aVelocity;
            _lifeTime = aLifeTime;
            _originalLifeTime = aLifeTime;
            _angle = aAngle;
            _angularVelocity = aAngularVelocity;
        }

        public Particle Update(float aElapsedTime)
        {
            _position = _position + _velocity * aElapsedTime;
            _angle += _angularVelocity * aElapsedTime;
            _lifeTime -= aElapsedTime;
            _color = new Color(new Vector4(_lifeTime / _originalLifeTime, _lifeTime / _originalLifeTime,
                                           _lifeTime / _originalLifeTime , _lifeTime / _originalLifeTime));
            return this;
        }

        public Vector2 GetPosition()
        {
            return _position;
        }
    }
}
